using System;
using PhillyCodeCamp.Domain;
using PhillyCodeCamp.DTO;
using PhillyCodeCamp.Infrastructure;
using PhillyCodeCamp.Services;

namespace PhillyCodeCamp.Mappers
{
    public class TaxReturnMapper : ITaxReturnMapper
    {
        private readonly ITaxRateService _taxRateService;

        public TaxReturnMapper (): this (DependencyResolver.Resolve<ITaxRateService>())
        {
            
        }
        public TaxReturnMapper(ITaxRateService taxRateService)
        {
            _taxRateService = taxRateService;
        }

        public ITaxReturn MapTaxReturn(TaxDataDTO taxDataDTO)
        {
            return new TaxReturn(
                Decimal.Parse(taxDataDTO.TotalIncome), 
                taxDataDTO.State,
                DateTime.Parse(taxDataDTO.Date), taxDataDTO.IsBailedOut, _taxRateService);
        }
    }
}